package com.example.cxf.config;

import com.example.cxf.service.IHello;
import org.apache.cxf.Bus;
import org.apache.cxf.jaxws.EndpointImpl;
import org.apache.cxf.transport.servlet.CXFServlet;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.boot.web.servlet.ServletRegistrationBean;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;

import javax.xml.ws.Endpoint;

/**
 * @author Mr.yuan
 * @version v1.0
 * @date 2019/12/31 19:19
 **/
@Configuration
public class CxfConfig {

    @Autowired
    private Bus bus;

    @Autowired
    private IHello iHello;

    @Bean
    public Endpoint studentServiceEndpoint(){
        EndpointImpl endpoint = new EndpointImpl(bus,iHello);
        endpoint.publish("/studentService");
        return endpoint;
    }
    @Bean
    public ServletRegistrationBean disServlet() {
        // 发布服务名称 localhost:8080/cxf
        return new ServletRegistrationBean(new CXFServlet(), "/cxf/*");

    }
}
